#+TITLE:Nginx EZ Cheatsheet
#+AUTHOR: Joshua Branson

* Tweaking the configuration file
** vocab
- simple directive
  =name parameter1 parameter2 parameter3:
- block directive
  A block directive has the syntax of a simple directive, but it surrounds text with two braces "{", "}".
  #+BEGIN_EXAMPLE
  name parameter1 parameter2 {
  # more programming type text goes here
  }
  #+END_EXAMPLE
- context
  A context is a block directive that has a block directive embedded in its braces.

  #+BEGIN_EXAMPLE
  events {
        name parameter1 parameter2 {

        }
  }
  #+END_EXAMPLE

  Any directive not in a context is considered to be in the main context.  The events and http context reside in the main context.  While the server context is in http, and location is in server.


 Nginx can have several server blocks with each block serving content from different websites.  You can also serve different content if a client accesses your site from a specific port.

Events and http reside in the main content.

Server is found in the http context, and location is always in a server context.
** You can have 2 location blocks in one server context

It's possible to have one server block get images from the /var/image/ directory and serve html files from the /usr/share/nginx
directory.

server {
    location / {
        root /usr/share/nginx;
    }

    location /images/ {
        root /var/image/;
    }
}

If a URI matches several location blocks, then nginx will serve the one with the longest prefix.  For example, GET images/pig.jpg matches both location blocks, BUT the second one has the longest prefix, so nginx serves the image from the second directory.
** check your changes for errors

#+BEGIN_SRC sh :results output :exports both
service nginx configtest  && service nginx restart
#+END_SRC
* tutorials for using nginx to serve more than 1 domain name

https://linode.com/docs/web-servers/nginx/how-to-configure-nginx/

https://wiki.archlinux.org/index.php/Nginx#Configuration

https://wiki.archlinux.org/index.php/Network_configuration#Local_network_hostname_resolution

https://wiki.archlinux.org/index.php/Network_configuration#Set_the_hostname

https://www.digitalocean.com/community/tutorials/how-to-set-up-nginx-server-blocks-virtual-hosts-on-ubuntu-14-04-lts

https://serverfault.com/questions/654652/multiple-domains-name-on-one-server-with-nginx/772320
* good online information for nginx
https://www.nginx.com/resources/wiki/start/
https://www.nginx.com/resources/wiki/start/topics/tutorials/config_pitfalls/
https://wiki.debian.org/Nginx/DirectoryStructure
* nginx and https
To configure nginx for https, one should probably just use
certbot.org.  aka let's encrypt by Mozilla.  However, nginx does need
to be able to read the certificates.  At the moment, it looks like it
can, but also any process on my computer can read the certificate.  I
should probably tweak the permissions a bit...
* installing lemp in arch linux
https://www.tecmint.com/install-nginx-php-mysql-with-mariadb-engine-and-phpmyadmin-in-arch-linux/
* optimizing nginx
https://bjornjohansen.no/optimizing-https-nginx
https://www.ssllabs.com/ssltest/analyze.html?d=www.gnusites.com
https://weakdh.org/
